var pageData = {
    "pageMenus": {
        "mid": 1,
        "menus": [
            {
                "id": 1,
                "title": "用户"
            },
            {
                "id": 2,
                "title": "机构"
            }
        ]
    },
    // 用户预约信息统计
    "userCount": [
        {
            "title": "待赴约",
            "count": null,
            "url": '/order/fy?flag=0'
        },
        {
            "title": "待评价",
            "count": null,
            "url": '/order/fy?flag=1'
        },
        {
            "title": "已完成",
            "count": null,
            "url": '/order/fy?flag=2'
        },
        {
            "title": "全部",
            "count": null,
            "url": '/order/fy?flag=4'
        }
    ],
    // 商户预约信息统计
    "merchantCount": [
        {
            "title": "待接待",
            "count": null,
            "url": "/merchant/toMoList?status=0"
        },
        {
            "title": "已违约",
            "count": null,
            "url": '/merchant/toMoList?status=3'
        },
        {
            "title": "已完成",
            "count": null,
            "url": '/merchant/toMoList?status=2'
        },
        {
            "title": "全部",
            "count": null,
            'url': '/merchant/toMoList?status=4'
        }
    ],
    "services": [
        /*{
            "id": 1,
            "title": "Tony老师特约造型设计",
            "image": "img/t1.png",
            "status": 1
        }*/
    ]
};
$.ajax({
    url: '/merchant/serviceList',
    type: 'post',
    dataType: 'json',
    success: function (result) {
        for(let i=0;i<result.length;i++){
            let service = {
                "id": result[i].cid,
                "title": result[i].ctitle,
                "image": result[i].cimages,
                "status": result[i].cstatus
            };
            pageData.services.push(service);
        }
    }
});

$(function () {

    // 识别是否来自商户申请页面
    var apply = getUrlParam("apply");
    if(apply != null){
        loginUser.merchant = true;
    }

    // 初始化Vue实例
    var vue = new Vue({
        el: "#app",
        data: {
            user: loginUser,
            pd: pageData
        },
        methods: {
            changeMenu: function (mid) {
                this.pd.pageMenus.mid = mid;
                $.ajax({
                    url: '/merchant/cusOrMer',
                    type: 'get',
                    success: function (result) {
                        //判断用户是否是商户
                        if(result != ''){
                            loginUser.merchant=true;
                        }
                    }
                })
            }
        }
    });

});
